<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich">
    <style type="text/css">
        .tableStyle{
            margin:10px 0px 5px 0px;
        }
        .gridStyle{
            margin:10px 10px 10px 0px;
        }
        input{
            margin:1px 1px 1px 2px;
        }
        input[type='submit']{
            margin:3px 5px 3px 5px;
            padding:2px 5px 2px 5px;
        }
    </style>
    <h:form id="aa">
        <rich:panel header="部门" id="deptPanel" styleClass="content-hight">
            <rich:messages/>
            <rich:toolbar  itemSeparator="grida" id="tolbar">
                <rich:toolbarGroup>
                    <a4j:commandButton value="新增" action="#{departmentBean.add}"
                                       execute="@this" render="tolbar,deptinfo"/>
                    <a4j:commandButton value="修改" action="#{departmentBean.update}"
                                       render="tolbar,deptinfo" execute="@this"
                                       disabled="#{departmentBean.addOrUpdate || departmentBean.node eq null}"/>
                    <a4j:commandButton value="删除" action="#{departmentBean.delete}"
                                       render="deptPanel" execute="@this"
                                       disabled="#{departmentBean.addOrUpdate || departmentBean.node eq null}"/>
                    <a4j:commandButton value="保存" action="#{departmentBean.checkSave}"
                                       render="deptPanel" execute="@form"
                                       disabled="#{!departmentBean.editStatus}"/>
                    <a4j:commandButton value="取消" action="#{departmentBean.cancel}" 
                                       render="tolbar,deptinfo" execute="@form" immediate="true"/>
                </rich:toolbarGroup>
            </rich:toolbar>
            <h:panelGrid columns="2" width="100%" border="0" id="mainform"> 
                <rich:tree value="#{departmentBean.rootNode}" var="idept"
                           selectionType="ajax" toggleType="client"
                           selectionChangeListener="#{departmentBean.selected}"
                           style="width:300px" render="deptinfo,tolbar">
                    <rich:treeNode>
                        <h:outputText value="[#{idept.data.code}]#{idept.data.name}" />
                    </rich:treeNode>
                </rich:tree>
                <h:panelGrid columns="2" id="deptinfo" styleClass="gridStyle">
                    <h:outputText value="部门代码:"/>
                    <h:inputText id="deptcode" value="#{departmentBean.node.code}"
                                 disabled="#{!departmentBean.editStatus || !departmentBean.addOrUpdate}"/>
                    <h:outputText value="部门名称:"/>
                    <h:inputText id="deptname" value="#{departmentBean.node.name}"
                                 disabled="#{!departmentBean.editStatus}"/>
                </h:panelGrid>
            </h:panelGrid>
        </rich:panel>
    </h:form>
</html>
